home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mush-7.1.1 / curs_io.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-02  |  17.4 KB  |  671 lines

  1. /* @(#)curs_io.c    (c) copyright 3/18/87 (Dan Heller) */
  2.  
  3. /* curs_io.c -- curses based I/O */
  4. #include "mush.h"
  5. #include "bindings.h"
  6. #include "glob.h"
  7.  
  8. static backspace();
  9.  
  10. #if !defined(M_XENIX) || (defined(M_XENIX) && !defined(CURSES))
  11. char *_unctrl[] = {
  12.     "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "^I", "^J", "^K",
  13.     "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W",
  14.     "^X", "^Y", "^Z", "^[", "^\\", "^]", "^~", "^_",
  15.     " ", "!", "\"", "#", "$",  "%", "&", "'", "(", ")", "*", "+", ",", "-",
  16.     ".", "/", "0",  "1", "2",  "3", "4", "5", "6", "7", "8", "9", ":", ";",
  17.     "<", "=", ">",  "?", "@",  "A", "B", "C", "D", "E", "F", "G", "H", "I",
  18.     "J", "K", "L",  "M", "N",  "O", "P", "Q", "R", "S", "T", "U", "V", "W",
  19.     "X", "Y", "Z",  "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e",
  20.     "f", "g", "h",  "i", "j",  "k", "l", "m", "n", "o", "p", "q", "r", "s",
  21.     "t", "u", "v",  "w", "x",  "y", "z", "{", "|", "}", "~", "^?"
  22. };
  23. #endif /* !M_XENIX || (M_XENIX && !CURSES) */
  24.  
  25. char    del_line;    /* tty delete line character */
  26. char    del_word;    /* tty delete word character */
  27. char    del_char;    /* backspace */
  28. char    reprint_line;    /* usually ^R */
  29. char    eofc;        /* usually ^D */
  30. char    lit_next;    /* usually ^V */
  31. char    complete;    /* word completion, usually ESC */
  32. char    complist;    /* completion listing, usually ^D */
  33.  
  34. tty_settings()
  35. {
  36.     savetty();
  37.  
  38. #ifdef SYSV
  39.     eofc = _tty.c_cc[VEOF];
  40. #else
  41. #ifdef BSD
  42.     if (ioctl(0, TIOCGETC, &tchars) != -1)
  43.     eofc = tchars.t_eofc;
  44.     else
  45. #endif /* BSD */
  46.     eofc = CTRL('D');
  47. #endif /* SYSV */
  48.  
  49.     if (!isatty(0)) {
  50.     del_line = CTRL('U');
  51.     del_char = CTRL('H');
  52.     } else {
  53.     del_line = _tty.sg_kill;
  54.     del_char = _tty.sg_erase;
  55.     }
  56.  
  57. #ifdef TIOCGLTC
  58.     if (ioctl(0, TIOCGLTC, <chars) != -1) {
  59.     del_word = ltchars.t_werasc;
  60.     reprint_line = ltchars.t_rprntc;
  61.     lit_next = ltchars.t_lnextc;
  62.     } else
  63. #endif /* TIOCGLTC */
  64.     {
  65.     del_word = CTRL('W');
  66.     reprint_line = CTRL('R');
  67.     lit_next = CTRL('V');
  68.     }
  69. }
  70.  
  71. #ifdef Addch
  72. #undef Addch
  73. #endif /* Addch */
  74.  
  75. #ifndef CURSES
  76.  
  77. /* Make sure all ifs have matching elses! */
  78.  
  79. #define Addch(c) \
  80.     if (ison(glob_flags, ECHO_FLAG)) \
  81.     {;} \
  82.     else \
  83.     (void) fputc(c, stdout), (void) fflush(stdout)
  84.  
  85. #else
  86.  
  87. /* see end of Getstr */
  88. #define Addch(c)  \
  89.     if (iscurses) \
  90.     addch(c), refresh(); \
  91.     else if (ison(glob_flags, ECHO_FLAG)) \
  92.     {;} \
  93.     else \
  94.     (void) fputc(c, stdout), (void) fflush(stdout)
  95. #endif /* CURSES */
  96.  
  97. /*
  98.  * get a string of at most 'length' chars.
  99.  * allow backspace-space-backspace, kill word and kill line
  100.  * (options set by user in stty).
  101.  * length is the max length this string can get. offset is from beginning
  102.  * of string.
  103.  * input of ^D returns -1; otherwise, return the number of chars in string.
  104.  */
  105. Getstr(String, length, offset)
  106. char String[];
  107. register int length;
  108. {
  109.     register int c, literal_next = FALSE, lit_bs = FALSE;
  110.     struct cmd_map *curr_map;
  111.     int count = offset, save_wc = wrapcolumn;
  112.  
  113.     (void) fflush(stdout); /* make sure everything is flushed before getting input */
  114.  
  115.     if (mac_hide) {
  116.     curr_map = NULL_MAP;
  117.     wrapcolumn = 0;
  118.     } else if (ison(glob_flags, IS_GETTING))
  119.     curr_map = bang_map;
  120.     else if (iscurses)
  121.     curr_map = NULL_MAP;
  122.     else
  123.     curr_map = line_map;
  124.  
  125.     while ((c = m_getchar()) != '\n' && c != '\r' && c != EOF &&
  126.         isoff(glob_flags, WAS_INTR)) {
  127.     /* echo isn't set, so whatever the character, enter it */
  128.     if (ison(glob_flags, QUOTE_MACRO) || ison(glob_flags, ECHO_FLAG)) {
  129.         if (count < length) {
  130.         String[count++] = c;
  131.         /* Note: Addch includes ECHO_FLAG test */
  132.         if (iscntrl(c)) {
  133.             Addch('^');
  134.             Addch(_unctrl[c][1]);
  135.         } else
  136.             Addch(c);
  137.         } else {
  138.         print("\nWarning: string too long. Truncated at %d chars.",
  139.             length);
  140.         if (ison(glob_flags, QUOTE_MACRO)) {
  141.             mac_flush();
  142.             m_ungetc(reprint_line);
  143.             continue;
  144.         } else
  145.             break;
  146.         }
  147.     }
  148.     /* ^D as the first char on a line or two ^D's in a row is EOF */
  149.     else if (c == eofc && !count)
  150.         break;
  151.     else if (c == '\\' && count < length) {
  152.         literal_next = TRUE, lit_bs = FALSE;
  153.         Addch(String[count++] = '\\');
  154.         } else if (c == lit_next && count < length) {
  155.         literal_next = lit_bs = TRUE;
  156.         String[count++] = '\\';
  157.         if (!in_macro()) {
  158.         /* if (iscntrl(c)) */
  159.             Addch('^');
  160.         /* Addch(_unctrl[c][1]); */
  161.         }
  162.     } else if (literal_next) {
  163.         struct cmd_map *list;
  164.  
  165.         literal_next = FALSE;
  166.         if (iscntrl(c) || c == del_line || c == del_char || c == del_word
  167.             || c == lit_next || lit_bs)
  168.         if (!in_macro() || !lit_bs)
  169.             backspace(String, &count);
  170.         else
  171.             --count;
  172.         else if (in_macro() && c == MAC_LONG_CMD)
  173.         --count;
  174.         /* check to see if user is escaping a map or map! */
  175.         else
  176.         for (list = curr_map; list; list = list->m_next)
  177.             if (list->m_str[0] == c) {
  178.             if (!in_macro())
  179.                 backspace(String, &count);
  180.             else
  181.                 --count;
  182.             break;
  183.             }
  184.         /* A literal-next advances the macro offset */
  185.         String[count++] = c;
  186.         if (iscntrl(c) || c == del_char) {
  187.         if (iscntrl(c)) {
  188.             /*
  189.              * Decrement wrapcolumn because two chars added.
  190.              * It will be restored from save_wc before return.
  191.              */
  192.             if (wrapcolumn > 1)
  193.             wrapcolumn--;
  194.             Addch('^');
  195.         }
  196.         Addch(_unctrl[c][1]);
  197.         } else
  198.         Addch(c);
  199.     } else if (complete && (c == complete || c == complist)) {
  200.         (void) completion(String, &count, (c == complist));
  201.     } else if (c == del_line) {
  202.         if (count) {
  203.         do
  204.             backspace(String, &count);
  205.         while (count);
  206.         }
  207.     } else if (c == reprint_line)
  208.         String[count] = 0, wprint("\n%s", String);
  209.     else if (c == del_word) /* word erase */
  210.         while (count) {
  211.         backspace(String, &count);
  212.         if (!count ||
  213.             isspace(String[count-1]) && !isspace(String[count]) ||
  214.             !isalnum(String[count-1]) && isalnum(String[count]))
  215.             break;
  216.         }
  217.     else if (c == del_char || c == CTRL('H') || c == 127 /* CTRL('?') */) {
  218.         if (count)
  219.         backspace(String, &count);
  220.         /* if iscurses, then backspacing too far cancels a function */
  221.         else if (!count && iscurses && isoff(glob_flags, LINE_MACRO)) {
  222.         mac_flush();
  223.         String[0] = '\0';
  224.         wrapcolumn = save_wc;
  225.         return -1;
  226.         }
  227.     } else if (count == length)
  228.         bell();
  229.     else if (c == '\t')
  230.         do  {
  231.         /* Yuck -- tabs break map! */
  232.         Addch(' ');
  233.         String[count] = ' ';
  234.         } while (++count % 8 && count < length);
  235.     else if (in_macro() && c == MAC_LONG_CMD) {
  236.         char cbuf[MAX_LONG_CMD + 1];
  237.  
  238.         if ((c = read_long_cmd(cbuf)) == 0) {
  239.         c = MAC_LONG_CMD;
  240.         goto check_expand;    /* How could I avoid this? */
  241.         } else if (c > 0) {
  242.         int ok;
  243.  
  244.         String[count] = '\0';
  245.         if ((ok = reserved_cmd(cbuf, TRUE)) > 0) {
  246.             /* Reprint the line */
  247.             if (iscurses)
  248.             print(":%s", String);
  249.             else
  250.             wprint("\r%s", String);
  251.             continue;    /* Get next char without changing count */
  252.         } else if (ok < 0) {
  253.             String[offset] = '\0';
  254.             wrapcolumn = save_wc;
  255.             return ok;
  256.         } else
  257.             goto push_back;
  258.         } else {
  259.         /*
  260.          * Ooops.  We read a bunch of stuff we should not
  261.          * have read, because this isn't really a long command.
  262.          * Use a trick to push the whole thing back, ala ungetc.
  263.          * Wouldn't it be nifty if stdio worked this way? :-)
  264.          */
  265. push_back:
  266.         if (c > 0) {
  267.             cbuf[c++] = MAC_LONG_END;
  268.             cbuf[c] = '\0';
  269.         }
  270.         c = MAC_LONG_CMD;
  271.         Ungetstr(cbuf);
  272.         goto check_expand;    /* How could I avoid this goto? */
  273.         }
  274.     } else {
  275. check_expand:
  276.         if (!curr_map || !check_map(c, curr_map)) {
  277.         /* else if (match != MATCH) */
  278.         if (c != '\t' && iscntrl(c)) {
  279.             Addch('^');
  280.             Addch(_unctrl[c][1]);
  281.             /* Decrement wrapcolumn as above */
  282.             if (wrapcolumn > 1)
  283.             wrapcolumn--;
  284.         } else
  285.             Addch(c);
  286.         String[count++] = c;
  287.         }
  288.     }
  289.     /* Null-terminate for macro lookup purposes.
  290.      * This will be overwritten by the next character.
  291.      */
  292.     String[count] = '\0';
  293.     if (line_wrap(String, &count))
  294.         break;
  295.     }
  296.     (void) fflush(stdout); /* for sys-v folks */
  297.  
  298.     if (c == eofc || c == EOF || ison(glob_flags, WAS_INTR)) {
  299.     if (feof(stdin))
  300.         clearerr(stdin);
  301.     wrapcolumn = save_wc;
  302.     return -1;
  303.     }
  304.     if (count && String[count-1] == '\\') {
  305.     int count2;
  306.     if (isoff(glob_flags, ECHO_FLAG))
  307.         putchar('\n');
  308.     wrapcolumn = save_wc;
  309.     /*
  310.      * NOTE: If the offset passed here is ever made greater than 0,
  311.      * the value of wrapcolumn must again be changed/restored ...
  312.      */
  313.     if ((count2 = Getstr(&String[count-1], length - count + 1, 0)) == -1)
  314.         return -1;
  315.     return count + count2;
  316.     }
  317.     if (!iscurses && isoff(glob_flags, ECHO_FLAG))
  318.     putchar('\n');
  319.     /* Should be null-terminated already, but just in case */
  320.     String[count] = '\0';
  321.     wrapcolumn = save_wc;
  322.     return count;
  323. }
  324.  
  325. static
  326. backspace(str, n)
  327. register char *str;
  328. int *n;
  329. {
  330.     (*n)--;
  331.     Addch('\b'); Addch(' '); Addch('\b');
  332.     if (iscntrl(str[*n])) {
  333.     Addch('\b'); Addch(' '); Addch('\b');
  334.     /* Re-increment wrapcolumn -- see Getstr */
  335.     if (wrapcolumn)
  336.         wrapcolumn++;
  337.     }
  338. }
  339.  
  340. #undef Addch
  341.  
  342. /*
  343.  * Check to see if what the user is typing is supposed to be expanded
  344.  * into a longer string.  The first char is 'c' and the map list to use
  345.  * is in map_list.  Continue looping (reading chars from stdin or a
  346.  * currently active mapping) until a match happens or we've determined
  347.  * that there is no match.
  348.  */
  349. check_map(c, map_list)
  350. char c;
  351. struct cmd_map *map_list;
  352. {
  353.     char mbuf[MAX_MACRO_LEN], *p = mbuf;
  354.     struct cmd_map *list;
  355.     int m, n, match;
  356.  
  357.     *p++ = c;
  358.  
  359.     while (isoff(glob_flags, WAS_INTR)) {
  360.     m = 0;
  361.     *p = 0; /* make sure it's null terminated */
  362.     /*
  363.      * loop thru the list of maps and check to see if the typed
  364.      * char matches the mapping.  If it matches completely, substitute
  365.      * the stuff in x_str and return.  If a partial match occurs, then
  366.      * read the next char until a timeout or no match.
  367.      */
  368.     for (list = map_list; list; list = list->m_next) {
  369.         if ((match = prefix(mbuf, list->m_str)) == MATCH) {
  370.         /* Must turn on flags BEFORE pushing */
  371.         line_macro(list->x_str);
  372.         return 1;
  373.         } else if (match != NO_MATCH)
  374.         m++; /* something matched partially */
  375.     }
  376.     if (!m)
  377.         break;
  378.     /* see if there's anything on the queue to read... */
  379.     if (mac_pending()
  380. #ifdef FIONREAD
  381.         || !ioctl(0, FIONREAD, &n) && n > 0
  382. #else
  383. #ifdef M_XENIX
  384.         || rdchk(0) > 0
  385. #endif /* M_XENIX */
  386. #endif /* FIONREAD */
  387.                            )
  388.         *p++ = m_getchar();
  389.     else {
  390.     /* The user has typed the first part of a map or macro.  Give him
  391.      * a chance to finish it.
  392.      */
  393. #if defined(BSD) || defined(SELECT)
  394.         /* If the system has select(), use it.  It's much faster and
  395.          * more aesthetic since there is no mandatory timeout.
  396.          */
  397.         struct timeval timer;
  398. #ifdef FD_SET
  399.         fd_set rmask, wmask, xmask;
  400.         FD_SET(0, &rmask);    /* Test stdin for read */
  401.         FD_ZERO(&wmask);    /* Don't care about write */
  402.         FD_ZERO(&xmask);    /* Don't care about exception */
  403. #else
  404.         int rmask = 1, wmask = 0, xmask = 0;
  405. #endif /* FD_SET */
  406.         timer.tv_sec = 1;
  407.         timer.tv_usec = 0;
  408.         n = select(1, &rmask, &wmask, &xmask, &timer);
  409. #else /* !SELECT */
  410. #ifdef FIONREAD
  411.         /* system doesn't have select(), so use FIONREAD to see if
  412.          * there are any chars on the queue to read.
  413.          */
  414.         (void) sleep(1);
  415.         (void) ioctl(0, FIONREAD, &n);
  416. #else
  417. #ifdef M_XENIX
  418.         (void) sleep(1);
  419.         n = rdchk(0);
  420. #else
  421.  
  422.         /* system has neither select() nor FIONREAD, so just set n
  423.          * and force the user to either complete the map or fail it
  424.          * without a timeout.  Chars won't echo till he does one or
  425.          * the other.
  426.          */
  427.         n = 1;
  428. #endif /* M_XENIX  */
  429. #endif /* FIONREAD */
  430. #endif /* SELECT */
  431.         if (n > 0)
  432.         /* don't read all 'n' chars -- there may be a match early */
  433.         *p++ = m_getchar();    /* To flush macros and reset flags */
  434.         else /* still nothing to read? User doesn't want to use map */
  435.         break;
  436.     }
  437.     }
  438.     /* no match or a timeout.  This isn't a map, just return. */
  439.     *p = 0;
  440.     if (mbuf[1])
  441.     (void) mac_push(mbuf + 1);
  442.     return 0;
  443. }
  444.  
  445. /*
  446.  * Check for line wrap.  This should happen only in composition mode and
  447.  * only when the variable wrapcolumn has a value greater than zero.  Line
  448.  * wrap is implemented using Ungetstr [that is, mac_push()].
  449.  *
  450.  * Returns 1 if the line was wrapped, 0 if not.
  451.  */
  452. line_wrap(string, count)
  453. char *string;    /* The string to be wrapped */
  454. int *count;    /* Offset of string terminator */
  455. {
  456.     char *tail = NULL;
  457.     int n = *count;
  458.  
  459.     if (wrapcolumn < 1 || *count <= wrapcolumn
  460.         || isoff(glob_flags, IS_GETTING)    /* Wrap only in msg body */
  461.         || ison(glob_flags, QUOTE_MACRO)    /* Don't wrap quoted macros */
  462.         || ison(glob_flags, ECHO_FLAG))    /* Can't wrap in echo mode */
  463.     return 0;
  464.  
  465.     /* Back up past the wrapcolumn point */
  466.     for (; n > wrapcolumn; --n)
  467.     ;
  468.     /* Look for a space */
  469.     while (n && !isspace(string[n]))
  470.     --n;
  471.     /* If no break found, return no wrap */
  472.     if (!n)
  473.     return 0;
  474.     tail = &string[n+1];
  475.     /* Skip the break char and any whitespace */
  476.     while (n && isspace(string[n]))
  477.     --n;
  478.     ++n; /* move back into the whitespace */
  479.     /* Erase the stuff that will wrap */
  480.     while (*count > n)
  481.     backspace(string,count);
  482.     string[*count] = '\0';
  483.     /* Push the tail, if any */
  484.     if (*tail)
  485.     Ungetstr(tail);
  486.     return 1;
  487. }
  488.  
  489. /*
  490.  * Error bell used by completion()
  491.  */
  492. errbell(ret)
  493. int ret;
  494. {
  495.     if (ret < 0 || !chk_option("quiet", "completion"))
  496.     bell();
  497.     return ret;
  498. }
  499.  
  500. /*
  501.  * Perform word completion on the input string
  502.  */
  503. completion(string, count, showlist)
  504. char *string;    /* The string to be completed */
  505. int *count;    /* Offset of string terminator */
  506. int showlist;    /* Display list, don't complete */
  507. {
  508.     char buf[MAXPATHLEN], *b = buf, **exp;
  509.     int n = *count, f, len, prefix, trim, overstrike, expandall;
  510.  
  511.     if (!*string || !*count)
  512.     return errbell(-1);
  513.  
  514.     /* Look for a delimiter */
  515.     while (n > 0 && !index(DELIM, string[--n]))
  516.     ;
  517.     if (n > 0 || index(DELIM, string[n]))
  518.     n++;
  519.     b = buf + (len = Strcpy(buf, &string[n]));
  520.     Debug("\nexpanding (%s) ... ", buf);
  521.     if (!any(buf, FMETA)) {
  522.     expandall = 0;
  523.     overstrike = (*buf == '+' || *buf == '~' || *buf == '%');
  524.     trim = (overstrike && len > 1);
  525.     if (!overstrike || len > 1 || (*buf == '+' && showlist))
  526.         *b++ = '*', *b = 0;
  527.     /* Previous behavior for '+' completions (trailing '/'):
  528.     if (len > 1 || *buf != '~' || *buf != '%')
  529.         *b++ = '*', *b = 0;
  530.     */
  531.     f = filexp(buf, &exp);
  532.     if (*--b == '*')
  533.         *b = 0; /* We need the original buf below */
  534.     } else {
  535.     overstrike = 1;
  536.     trim = (*buf == '+' || *buf == '~');
  537.     /*
  538.      * Check first to see if the base pattern matches.
  539.      * If not, append a '*' and try again.
  540.      * Don't expand all matches in the latter case.
  541.      */
  542.     if ((f = filexp(buf, &exp)) < 1) {
  543.         *b++ = '*', *b = 0;
  544.         f = filexp(buf, &exp);
  545.         *--b = 0; /* We need the original buf below */
  546.         expandall = 0;
  547.     } else
  548.         expandall = 1;
  549.     }
  550.     if (!showlist)
  551.     f = fignore(f, &exp);
  552.     if (f < 0) {
  553.     Debug("globbing error!\n%s", string);
  554.     free_vec(exp);
  555.     return errbell(-1);
  556.     } else if (f > 0) {
  557.     Debug("result is: "), print_argv(exp);
  558.     if (!expandall && f > 1)
  559.         prefix = lcprefix(exp, overstrike ? 0 : len);
  560.     else
  561.         prefix = 0;
  562.     if (showlist) {
  563.         if (!expandall && f > 1)
  564.         while (prefix && exp[0][prefix - 1] != '/')
  565.             --prefix;
  566.         putchar('\n');
  567.         if (columnate(f, exp, prefix) < 0)
  568.         (void) errbell(-1);
  569.         /* Reprint the line */
  570.         if (iscurses) {
  571.         wprint(":%s", string);
  572.         turnon(glob_flags, CNTD_CMD);
  573.         } else {
  574.         if (isoff(glob_flags, IS_GETTING))
  575.             mail_status(1);
  576.         wprint("%s", string);
  577.         }
  578.     } else if (expandall || strlen(exp[0]) > len) {
  579.         Debug("%s", string);
  580.         if (overstrike && (prefix || expandall || f == 1)) {
  581.         char *tmpv[3];
  582.         tmpv[0] = buf;
  583.         if (trim)
  584.             tmpv[1] = trim_filename(exp[0]);
  585.         else
  586.             tmpv[1] = exp[0];
  587.         tmpv[2] = NULL;
  588.         /* Back up as far as is necessary */
  589.         len = lcprefix(tmpv, 0);
  590.         /* If nothing will be erased, we may need to beep */
  591.         if (n + len == *count) {
  592.             if (!expandall && !tmpv[1][len])
  593.             (void) errbell(0);
  594.         }
  595.         /* Erase the stuff that will complete */
  596.         while (*count > n + len)
  597.             backspace(string,count);
  598.         string[*count] = '\0';
  599.         }
  600.         if (expandall || f == 1) {
  601.         /* Unget the names IN REVERSE ORDER! */
  602.         while (f--) {
  603.             if (trim)
  604.             b = trim_filename(exp[f]);
  605.             else
  606.             b = exp[f];
  607.             if (f) {
  608.             Ungetstr(b);
  609.             Ungetstr(" ");
  610.             } else
  611.             Ungetstr(b + len);
  612.         }
  613.         } else {
  614.         if (prefix > len) {
  615.             exp[0][prefix] = 0;
  616.             Debug("\ncompletion is (%s)\n%s", exp[0], string);
  617.             if (trim)
  618.             Ungetstr(trim_filename(exp[0]) + len);
  619.             else
  620.             Ungetstr(&exp[0][len]);
  621.         } else
  622.             Debug("\nno longer prefix\n%s", string);
  623.         /* Special case because "+" always tries to expand "+*"
  624.          * to get listings and avoid getpath()'s trailing '/'.
  625.          * No error bell is needed in those cases.
  626.          */
  627.         if (strcmp(buf, "+") != 0)
  628.             (void) errbell(0);
  629.         }
  630.     } else {
  631.         Debug("no longer prefix\n%s", string);
  632.         (void) errbell(0);
  633.     }
  634.     } else {
  635.     Debug("no match\n%s", string);
  636.     (void) errbell(0);
  637.     }
  638.     free_vec(exp);
  639.     return 1;
  640. }
  641.  
  642. fignore(argc, argvp)
  643. int argc;
  644. char ***argvp;
  645. {
  646.     char *fign = do_set(set_options, "fignore");
  647.     char **flist, buf[MAXPATHLEN], *b = buf;
  648.     int fcnt, i;
  649.  
  650.     if (argc < 2 || !fign || !*fign)
  651.     return argc;
  652.     if (!argvp || !*argvp && !**argvp)
  653.     return -1;
  654.     
  655.     if ((flist = mk_argv(fign, &fcnt, FALSE)) && fcnt > 0) {
  656.     *b++ = '*';
  657.     for (i = 0; i < fcnt; i++) {
  658.         if (flist[i][0] == '.' && !any(flist[i], FMETA)) {
  659.         (void) strcpy(b, flist[i]);
  660.         (void) strdup(flist[i], buf);
  661.         }
  662.     }
  663.     Debug("ignoring "), print_argv(flist);
  664.     fcnt = gdiffv(argc, argvp, fcnt, flist);
  665.     free_vec(flist);
  666.     if (fcnt == 0)
  667.         fcnt = argc;
  668.     }
  669.     return fcnt;
  670. }
  671.